package com.example.nativedemo;

import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.core.annotation.Order;

import com.example.nativedemo.mapper.MessageMapper;
import com.example.nativedemo.mapper.MessageXmlMapper;

@SpringBootApplication
public class NativeDemoApplication {

	public static void main(String[] args) {
		SpringApplication.run(NativeDemoApplication.class, args);
	}

	@Bean
	@Order(1)
	ApplicationRunner run(MessageMapper mapper) {
		return args -> {
			mapper.insertSelective(new Message(null, "Hello World on run!"));
			Message message = mapper.selectOneById(1);
			System.out.println(message);
		};
	}

	@Bean
	@Order(2)
	ApplicationRunner runWithXmlMapper(MessageXmlMapper xmlMapper) {
		return args -> {
			xmlMapper.insert(new Message(null, "Hello World on run with XML!"));
			Message message = xmlMapper.selectOneById(2);
			System.out.println(message);
		};
	}
}
